package org.concurrent.threadPool;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class MyThreadFactory {
	
	private ThreadFactory getThreadFactory(final String threadName) {
		return new ThreadFactory() {
			
			AtomicInteger sn = new AtomicInteger();
			
			public Thread newThread(Runnable r) {
				
				SecurityManager s = System.getSecurityManager();
                ThreadGroup group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
                Thread t = new Thread(group, r);
                t.setName(threadName+"-" + sn.incrementAndGet());
                return t;
			}
		};
	}
}
